package com.dishdex.menuhub.app.controller;

import com.dishdex.menuhub.module.utils.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName:
 * Package: com.dishdex.menuhub.app.controller
 * Description:
 *
 * @Author:
 * @Create 2025/10/22 9:19
 * @Version 1.0
 */
@Slf4j
@ControllerAdvice
public class GlobalControllerAdvice {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    Response handleControllerException(Exception ex) {
        log.error("全局异常: {}", ex.getStackTrace(), ex);

        return new Response(4004, ex.getStackTrace());
    }
}
